package com.sz.web.account.mapper;

import com.sz.web.account.entity.AccountFunction;
import com.sz.web.common.mapper.MyMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AccountFunctionMapper extends MyMapper<AccountFunction> {

    @Select("select id,create_time,update_time,function_name,status,control_url from account_function where control_url = #{controlUrl}")
    AccountFunction selectByControlUrl(@Param("controlUrl") String controlUrl);

    @Select("select count(*) from account_function where control_url = #{controlUrl}")
    int selectCountByControlUrl(@Param("controlUrl") String controlUrl);

    @Select("SELECT fun.* FROM account_function fun LEFT JOIN account_role_function roleFun ON fun.id=roleFun.function_id LEFT JOIN account_role role ON roleFun.role_id=role.id WHERE role.id = #{id}")
    List<AccountFunction> selectByRoleId(@Param("id") Integer id);

}
